package com.uzai.console.web.wxpub;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.BaseDto;
import com.uzai.console.dto.wxpub.activecode.*;
import com.uzai.console.entity.wxpubmanage.WxpubInfoEntity;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.wxpub.WxpubActiveCodeService;
import com.uzai.console.vo.wxpub.activecode.WxpubActiveCodeDetailVo;
import com.uzai.console.vo.wxpub.activecode.WxpubActiveCodeVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author liuqi
 * @date 2021年08月25日 20:15
 */
@Api(value = "公众号管理",tags = "活码管理|公众号管理")
@ApiSort(15)
@RestController
public class WxpubActiveCodeContoller extends BaseController {
    private Logger logger = LoggerFactory.getLogger(WxpubActiveCodeContoller.class);

    @Autowired
    private WxpubActiveCodeService wxpubActiveCodeService;


    @ApiOperation(value = "分页查询活码管理列表", notes = "分页查询活码管理列表", response = WxpubActiveCodeVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/wxpubActiveCode/findByPage")
    public Object findWxpubActiveCodeList(@RequestBody WxpubActiveCodeQuery wxpubActiveCodeQuery){
        return wxpubActiveCodeService.findWxpubActiveCodePage(wxpubActiveCodeQuery);
    }

    @ApiOperation(value = "根据id查询活码管理", notes = "根据id查询活码管理", response = WxpubActiveCodeVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/wxpubActiveCode/fingById")
    public Object findWxpubActiveCodeInfo(@RequestBody WxpubActiveCodeIdDto wxpubActiveCodeIdDto){
        return wxpubActiveCodeService.findWxpubActiveCode(wxpubActiveCodeIdDto);
    }

    @SystemLogType(model = SystemModelEnum.WxpubActiveCode, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加活码管理", notes = "添加活码管理")
    @ApiOperationSupport(order = 3)
    @PostMapping("/wxpubActiveCode/add")
    public Object addWxpubActiveCode(@RequestBody WxpubActiveCodeDto wxpubActiveCodeDto){
        wxpubActiveCodeService.addWxpubActiveCode(wxpubActiveCodeDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.WxpubActiveCode, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "追加活码管理", notes = "追加活码管理")
    @ApiOperationSupport(order = 3)
    @PostMapping("/wxpubActiveCode/additional")
    public Object additionalWxpubActiveCode(@RequestBody WxpubActiveCodeDto wxpubActiveCodeDto){
        wxpubActiveCodeService.additionalWxpubActiveCode(wxpubActiveCodeDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.WxpubActiveCode, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "修改活码管理公众号", notes = "修改活码管理公众号")
    @ApiOperationSupport(order = 6)
    @PostMapping("/wxpubActiveCode/updateWxpub")
    public Object updateWxpub(@RequestBody UpdateWxpubDto updateWxpubDto){
        wxpubActiveCodeService.updateWxpub(updateWxpubDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.WxpubActiveCode, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "修改活码管理名称", notes = "修改活码管理名称")
    @ApiOperationSupport(order = 6)
    @PostMapping("/wxpubActiveCode/updateActiveCodeName")
    public Object updateActiveCodeName(@RequestBody UpdateActiveCodeNameDto updateActiveCodeNameDto){
        wxpubActiveCodeService.updateActiveCodeName(updateActiveCodeNameDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.WxpubActiveCode, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除活码管理", notes = "删除活码管理")
    @ApiOperationSupport(order = 7)
    @PostMapping("/wxpubActiveCode/deleteById")
    public Object deleteWxpubActiveCode(@RequestBody WxpubActiveCodeIdDto wxpubActiveCodeIdDto){
        wxpubActiveCodeService.deleteActiveCode(wxpubActiveCodeIdDto);
        return true;
    }

    @ApiOperation(value = "分页查询活码管理明细列表", notes = "分页查询活码管理明细列表", response = WxpubActiveCodeDetailVo.class)
    @ApiOperationSupport(order = 8)
    @PostMapping("/wxpubActiveCode/detail/findByPage")
    public Object findWxpubActiveCodeDetailPage(@RequestBody WxpubActiveCodeDetailQuery wxpubActiveCodeDetailQuery){
        return wxpubActiveCodeService.findWxpubActiveCodeDetailPage(wxpubActiveCodeDetailQuery);
    }

    @ApiOperation(value = "根据id查询活码管理明细", notes = "根据id查询活码管理明细", response = WxpubActiveCodeVo.class)
    @ApiOperationSupport(order = 9)
    @PostMapping("/wxpubActiveCode/detail/fingById")
    public Object findWxpubActiveCodeDetail(@RequestBody WxpubActiveCodeDetailIdDto wxpubActiveCodeDetailIdDto){
        return wxpubActiveCodeService.findWxpubActiveCodeDetail(wxpubActiveCodeDetailIdDto);
    }

    @SystemLogType(model = SystemModelEnum.WxpubActiveCodeDetai, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除活码管理明细", notes = "删除活码管理明细")
    @ApiOperationSupport(order = 10)
    @PostMapping("/wxpubActiveCode/detail/deleteById")
    public Object deleteActiveCodeDetail(@RequestBody WxpubActiveCodeDetailIdDto wxpubActiveCodeDetailIdDto){
        wxpubActiveCodeService.deleteActiveCodeDetail(wxpubActiveCodeDetailIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.WxpubActiveCodeDetai, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "修改活码管理明细", notes = "修改活码管理明细")
    @ApiOperationSupport(order = 13)
    @PostMapping("/wxpubActiveCode/detail/update")
    public Object updateWxpubActiveCodeGroup(@RequestBody WxpubActiveCodeDetailDto wxpubActiveCodeDetailDto){
        wxpubActiveCodeService.updateWxpubActiveCodeDetail(wxpubActiveCodeDetailDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.WxpubActiveCodeDetai, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "修改活码管理明细页面排序", notes = "修改活码管理明细页面排序")
    @ApiOperationSupport(order = 13)
    @PostMapping("/wxpubActiveCode/detail/updatePageOrder")
    public Object updatePageOrder(@RequestBody UpdatePageOrderDto updatePageOrderDto){
        wxpubActiveCodeService.updatePageOrder(updatePageOrderDto);
        return true;
    }

    @ApiOperation(value = "活码管理查询公众号列表", notes = "活码管理查询公众号列表", response = WxpubInfoEntity.class)
    @ApiOperationSupport(order = 14)
    @PostMapping("/wxpubActiveCode/wxpub/findByList")
    public Object findWxpubList(@RequestBody BaseDto baseDto){
        return wxpubActiveCodeService.findWxpubList(baseDto);
    }

    @ApiOperation(value = "生成带参二维码", notes = "生成带参二维码", response = Object.class)
    @ApiOperationSupport(order = 15)
    @PostMapping("/wxpubActiveCode/wxpub/createQrcode")
    public Object createQrcode(@RequestBody WxpubActiveCodeIdDto wxpubActiveCodeIdDto){
        return wxpubActiveCodeService.createQrcode(wxpubActiveCodeIdDto);
    }


}
